<?php
//Test stuff, not even slightly finished
//Init variables
$t1_score = $_POST["t1_score"];
$t2_score = $_POST["t2_score"];
$game_date = $_POST["game_date"];

//We need the DB code and the functions
require ('functions.inc.php');
require ('dbconn.inc.php');

  print ("<html>");
  print ("<head>");
  print ("<title>Add Match</title>");
  print ("</head>");
  print ("<body>");

if (!isset($_POST['submit']))
{ // if page is not submitted to itself generate the form


  //Output the dropdowns and score boxes. NB Need to add checking to score input

  print ("<form name=\"addmatch\" action=\"$PHP_SELF\" method=\"POST\">");
  print ("<br /><br />Game date (YYYY-MM-DD):<input type=\"text\" size=\"10\" maxlength=\"10\" name=\"game_date\"><br />");
  print ("<input type=\"submit\" value=\"submit\" name=\"submit\">");
  print ("</form>");
}
//The following runs if the form has been submitted
else
{

$add_match_sql = "INSERT INTO matches SET
                    date = '$game_date'";

$add_match_result = @mysql_query($add_match_sql);

if (!$add_match_result)
     {
  	       exit("<p>Error adding data game. Additional details: " . mysql_error() . "</p><br />");
     }
else
    {
           print ("<p>Match added for $game_date</p>");
    }

}
    print ("</body>");
    print ("</html>");
?>